<!--
 * @Description: 
 * @Author: charles
 * @Date: 2021-05-05 22:02:56
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-01-08 00:50:04
-->
<template>
  <!--1. 容器 -->
  <div ref="left1_container"  style="height: 95%"></div>
</template>

<script>
// 引入antv
import {Line} from "@antv/g2plot";
import {get} from '../../../utils/request';
import moment from 'moment';

export default {
  data() {
    return {
      dataArr:[]
    }
  },
  created() {
    
  },
  mounted() {
    this.initData();
  },
  methods: {
    initData(){
      get('/dashboard/pageQueryTodayData',{
        page: 1,
        pageSize: 5,
        device_id:1
      }).then(res=>{
        res.data.list.forEach(item=>{
          item.dataTime=moment(item.insert_time).format('HH:mm')
        })
        this.dataArr=res.data.list
        this.initChart()
      })
      

    },

    // 创建一个实例对象
    initChart(){
      const linePlot = new Line(this.$refs.left1_container, {
        data: this.dataArr,
        xField: 'dataTime',
        yField: 'temperature',
       
        
      });
      // 渲染图像
      linePlot.render();



    }

  },
}
</script>>

<style scoped>

</style>